set more off
**cd "/Users/cason/Dropbox/Research/Gender_groups/data"
**cd "C:\Research\Gender_groups\data"
cd "C:\Users\cason\Dropbox\Research\Gender_groups\data\data2021\"

** Combine the choices in the coordination game of Part 1 **

use subPart1_13sess.dta

** How many OTHER women are in the group of 2 other Type Cs **

gen numOtherFem=genderC1+genderC2-2

** Create a gender ID variable *

gen FemaleID=gender-1

** Create an ID variable = 1 if choice 2 is selected **
gen Choice2ID = typeCAction - 1
** Choice 2 is always the kinder choice **

** Now merge in the coded chat data **
sort sessnum Period ID

merge 1:m sessnum Period ID using sorted_coded_21.dta
drop if _merge==1

** Mean frequency of chat statements (Table 6) **
sum q1ave q2ave q3ave q3aave q3bave q4ave q5mave q5jave q6ave q7ave q8ave q9ave q9mave q9jave q10ave q11mave q11jave
** Separated by gender for Table 7 **
bysort FemaleID: sum q1ave q2ave q3ave q3aave q3bave q4ave q5mave q5jave q6ave q7ave q8ave q9ave q9mave q9jave q10ave q11mave q11jave

** assess reliability : Table 6 (Cohen's Kappa) **
kap q1c1 q1c2 q1c3
kap q2c1 q2c2 q2c3
kap q3c1 q3c2 q3c3
kap q3ac1 q3ac2 q3ac3
kap q3bc1 q3bc2 q3bc3
kap q4c1 q4c2 q4c3
kap q5mc1 q5mc2 q5mc3
kap q5jc1 q5jc2 q5jc3
kap q6c1 q6c2 q6c3
kap q7c1 q7c2 q7c3
kap q8c1 q8c2 q8c3
kap q9c1 q9c2 q9c3
kap q9mc1 q9mc2 q9mc3
kap q9jc1 q9jc2 q9jc3
kap q10c1 q10c2 q10c3
kap q11mc1 q11mc2 q11mc3
kap q11jc1 q11jc2 q11jc3

** Count number of times out of 3 coders a category was identified **
gen q1sum=(q1c1+q1c2+q1c3)
replace q1sum=0 if q1sum==.
gen q2sum=(q2c1+q2c2+q2c3)
replace q2sum=0 if q2sum==.
gen q3sum=(q3c1+q3c2+q3c3)
replace q3sum=0 if q3sum==.
gen q3asum=(q3ac1+q3ac2+q3ac3)
replace q3asum=0 if q3asum==.
gen q3bsum=(q3bc1+q3bc2+q3bc3)
replace q3bsum=0 if q3bsum==.
gen q4sum=(q4c1+q4c2+q4c3)
replace q4sum=0 if q4sum==.
gen q5msum=(q5mc1+q5mc2+q5mc3)
replace q5msum=0 if q5msum==.
gen q5jsum=(q5jc1+q5jc2+q5jc3)
replace q5jsum=0 if q5jsum==.
gen q6sum=(q6c1+q6c2+q6c3)
replace q6sum=0 if q6sum==.
gen q7sum=(q7c1+q7c2+q7c3)
replace q7sum=0 if q7sum==.
gen q8sum=(q8c1+q8c2+q8c3)
replace q8sum=0 if q8sum==.
gen q9sum=(q9c1+q9c2+q9c3)
replace q9sum=0 if q9sum==.
gen q9msum=(q9mc1+q9mc2+q9mc3)
replace q9msum=0 if q9msum==.
gen q9jsum=(q9jc1+q9jc2+q9jc3)
replace q9jsum=0 if q9jsum==.
gen q10sum=(q10c1+q10c2+q10c3)
replace q10sum=0 if q10sum==.
gen q11msum=(q11mc1+q11mc2+q11mc3)
replace q11msum=0 if q11msum==.
gen q11jsum=(q11jc1+q11jc2+q11jc3)
replace q11jsum=0 if q11jsum==.

drop _merge
gen subsess=sessnum+Subject

** Test for differences by gender of various codes (Table 7) **
poisson q1sum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q2sum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q3sum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q3asum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q3bsum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q4sum FemaleID if payoffCase==1, vce(cluster subsess)
*poisson q5m_9msum FemaleID if payoffCase==1, vce(cluster subsess)
*poisson q5j_9jsum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q5msum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q5jsum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q6sum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q7sum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q8sum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q9sum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q9msum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q9jsum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q11msum FemaleID if payoffCase==1, vce(cluster subsess)
poisson q11jsum FemaleID if payoffCase==1, vce(cluster subsess)

** Count and compare overall chat volume and also summarize total counts of statements **
collapse (count) q11jave (sum) q1sum q2sum q3sum q3asum q3bsum q4sum q5msum q5jsum q6sum q7sum q8sum q9sum q9msum q9jsum q11msum q11jsum, by(Period typeCAction FemaleID sessnum subsess payoffCase Group infoProvided)
rename q11jave linecounts

** Final row of Table 7 **
tabstat linecounts, statistics( mean median min max ) by(FemaleID)
poisson linecounts FemaleID if payoffCase==1, vce(cluster subsess)


